home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qlib205.zip / QLIB.ZIP / C / PASM.C < prev    next >
C/C++ Source or Header  |  1997-04-14  |  3KB  |  108 lines

  1. //#define DEBUG  ;test file IO
  2. //#define DEBUG2  ;test pasm
  3. //#define DEBUG3  ;test readln
  4.  
  5. // PreASMmbler v1.2  32bit
  6. //  By:Peter Quiring
  7.  
  8. /*----------------------------------------------------------------------------
  9.  Version 1.20 NEW : handles single quotes into double quotes (you no longer
  10.                     need to double them up yourself
  11.  Version 1.11 NEW : expand /t into tab
  12.  Version 1.10 NEW : no extra spaces between 'include' and 'file' were allowed
  13.                   : major improvment in error handling
  14.                   : \" will work now (use to have to use "" - which will still work)
  15.                   : null strings now work
  16.  Version 1.04 NEW : Now the INCLUDE enviro str can have multiple paths
  17.                   : seperated by ;
  18.  Version 1.03 NEW : 32bit using DOS32
  19.                   : Buffered input/output  (greatly increases speed!)
  20.                   : \r=13, \n=10, \0=0  (\n use to =13,10)
  21.  Version 1.02 NEW : \0 will insert a ,0, into the string
  22.  Version 1.01 NEW : Now handles comment blocks
  23.  
  24. known bugs: v1.0
  25.  -none
  26. known bugs: v0.1 ßeta
  27.  -can't not have ; or ' or " within quotes
  28.  
  29.    Current version
  30. limitations:
  31.  - Keeps all files open (until they are done), so you need a handle for
  32.    each file when there are includes...
  33. future improvments:
  34.  -merge duplicate strings (now I could with 32bit power - so much RAM)
  35. ----------------------------------------------------------------------------*/
  36.  
  37. #include <qlib.h>
  38. #include <string.h>
  39. #include <dos.h>
  40. #include <stdlib.h>
  41. #include <stdio.h>
  42. #include <conio.h>
  43. #include <fcntl.h>
  44.  
  45. #define mh 64   //max handles  (the incs)
  46. #define bufsiz 8*1024  //buffer size  (BUG! make larger after debugging)
  47. byte buf[256];  //current line
  48. byte *bufo1;
  49. byte *bufo2;
  50. word bufp1,bufp2;
  51. byte * bufin[mh];
  52. word bufip[mh];
  53. word bufis[mh];
  54. byte buffn[mh][80];
  55. word bufln[mh];
  56. word cnum;  //current string number
  57. int ho1;  // handle out for large ASM file  (asm.tmp)
  58. byte ho1on;  //handle above has been created
  59. int ho2;  // handle out for special data segment! (_str_.tmp)
  60. int h;       // current file handle
  61. int hs[mh];  // handles  (all kept in place)  (requires a lot of handles in config.sys)
  62. byte ch;     // current handle #
  63. byte foundit; // flag to indicate we found #include!
  64. byte EOFF[mh];     // flag (indicates that we have hit EOF)
  65. //byte EOFF2[mh];    // flag (indicates that the current buffer is last one)
  66. byte *file;  //pts to filename to open
  67. byte str[255];
  68. byte str2[255];
  69. byte str3[255];
  70. byte enter[3]={13,10,0};
  71. byte *inc;  //INCLUDE name from enviroment
  72. word incsiz;  //size of inc string
  73. byte t2[80];
  74. byte anulstr;
  75.  
  76. void flush(void);
  77.  
  78. void prefile(void);
  79.  
  80. #include "err-p.h"
  81. #include "readln.h"
  82. #include "do.h"
  83. #include "pasm.h"
  84.  
  85. void main(void) {
  86.   byte a;
  87.   printf("Pre Assembler v1.2 32bit (by : Peter Quiring)\n");
  88.   ho1on=0;
  89.   bufp1=0;
  90.   bufp2=0;
  91.   bufo1=(void *)malloc(bufsiz);
  92.   bufo2=(void *)malloc(bufsiz);
  93.   if ( ((dword)bufo1==ERROR) || ((dword)bufo2==ERROR) ) error("Out of RAM\n");
  94.   for(a=0;a<mh;a++) bufin[a]=0;
  95.   if (_argc!=2) error("Usage: PASM 'file.asm'");
  96.   file=_argv[1];
  97.   ch=(unsigned)255;
  98.   foundit=0;
  99.   cnum=0;
  100.   setup();
  101.   dofile();
  102.   flush();
  103.   if (!foundit) printf("Warning:'#include' was not found\n");
  104.   printf("Complete!\n\n");
  105.   exit(0);
  106. }
  107.  
  108.